import http from '@/utils/request';

interface ShareParams {
    bookId: string;
    type: 'readonly' | 'readwrite';
    shareCount: number;
    shareUserId: string;
}

/**
 * 保存分享记录
 * @param params 分享参数
 * @returns Promise
 */
export const saveShare = (params: ShareParams) => {
    return http.post('/system/share', params);
};

// 获取我的分享列表
export const getMyShareList = (params: {
    pageNum: number;
    pageSize: number;
    title?: string;
}) => {
    return http.post('/system/share/myShareBook', params)
}

// 删除分享
export const deleteShare = (id: number) => {
    return http.delete(`/system/share/${id}`)
}

// 创建分享
export const createShare = (data: {
    bookId: number;
    type: string;
}) => {
    return http.post('/system/share', data)
}

// 取消分享
export const cancelShare = (id: string) => {
    return http.delete(`/system/share?id=${id}`);
};
